//
//  HomeViewController.swift
//  SwiftDemo
//
//  Created by hs on 2017/7/10.
//  Copyright © 2017年 jiachen. All rights reserved.
//

import UIKit

class HomeViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource{
    let p1 = Student("Tom",("math","A"),"1.jpg")
    //MARK:UITableViewDataSource
    @available(iOS 2.0, *)
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    @available(iOS 2.0, *)
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "OneTableViewCell") as! OneTableViewCell
        
        cell.setStudent(p1)
//        cell?.textLabel?.text = "第\(indexPath.row)行"
//        cell?.imageView?.image = UIImage.init(named: "1.jpg")
//        cell?.detailTextLabel?.text = "testxxx"
        return cell
        
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let button:UIButton = UIButton(type:.contactAdd)
        button.frame=CGRect(x:10,y:20,width:100,height:50)
        button.setTitle("按钮", for:UIControlState.normal )
        button.backgroundColor = UIColor.red
        button.addTarget(self,action:#selector(HomeViewController.exitAction),for:.touchUpInside)
        self.view .addSubview(button)
        
        let tab = UITableView.init(frame: CGRect.init(x: 0, y:70, width:self.view.frame.width , height:self.view.frame.height-70), style: UITableViewStyle.plain)
        tab.dataSource = self
        tab.delegate = self
        tab.separatorStyle = UITableViewCellSeparatorStyle.none
        
        tab.register(OneTableViewCell.self, forCellReuseIdentifier:"OneTableViewCell")
        self.view.addSubview(tab)
        
        // Do any additional setup after loading the view.
    }
    
    @objc func exitAction() {
        let vc = ViewController.init()
        vc.decrease()
        
    
        self.dismiss(animated: true) {
            
        };
        
    }
    override func updateViewUI() {
        super.updateViewUI()
        
    }
    
    //MARK:UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100.0;
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
